<template>
  <div class="container Courseware">
      <outerBox title="课件">

        <div v-if="list.length">
          <el-row :gutter="30">
            <el-col :span='8' class="_list marginT20" :key="l"
        v-for="(itemList , l ) in  list">
        <div>
       <fileList :options="{title:'name',url:'files'}" :list='itemList'></fileList>

       <div v-if="itemList.tagList" class="textHide l1">
       <el-tag :key="t"
       class="mar"
       v-for="(item , t ) in  itemList.tagList">{{item.tagName}}</el-tag>
       </div>
       </div>
       </el-col>
       </el-row>
        </div>
      </outerBox>
  </div>
</template>

<script>
    import fileList from './fileList'
  import outerBox from '@/components/outerBox'
  import {
    getTemplate
  } from '@/api/createResult'
  // import DPlayer from '@/components/DPlayer'
  export default {
    name: 'CoursewareInfo',
    components: {
      outerBox,
      fileList
    },
    data() {
      return {
        importTagList: [],
        info:{
          filesId:[],//参考资料文件URl
          referVal:'',
          templateWocUrl:''
        },

      }
    },
    watch:{
      list:{
        handler:function(val){
        this.fetchData()
      },
      immediate:true
      }
    },
    created() {

    },
    mounted() {
      //
    },
    watch:{
      list:{
        handler(){

        },
        imeediate:true
      }
    },
    props:{
    list:{
      type:[Object,Array],
    	default:[]
      },
    teachingDesignResId:{
      default:'',
    },
    },
    computed: {
      teachingDesignId() {
        return this.$store.state.uploadLessonPlan.teachingPlanId
      },
    },
    methods: {
      fetchData(){
        let {list,info,idGetTagList} = this

        if(list.files)  info.fileIds = list.files.split(',')
        
        this.importTagList=idGetTagList(list.tagList)
        console.log("warseList",this.importTagList)
      },
      idGetTagList(taglist) {
        let newTages = []
        //
        if (!taglist) return newTages;
        if(!taglist.filter(item=>Boolean(item.tagId)===true).length) return taglist;
        if (Array.isArray(taglist)) {
          taglist.forEach(tag => {
            let b = {}
            b[tag['tagName']] = []
            console.log('d919174106b3951f tag sdsd',tag)
            for (let tagsId in tag.tags) {
              let tagsName = tag.tags[tagsId]
              b[tag['tagName']].push({
                tagsId,
                tagsName
              })
            }
            newTages.push(b)
          })
        }
        return newTages
      },
    }

  }
</script>
<style lang="scss">

</style>
<style lang="scss" scoped>
  .container {


  }
</style>
